package com.chinamobile.maps.util;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.MDC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.chinamobile.maps.action.LoginAction;
import com.opensymphony.xwork2.ActionContext;

/**
 * @ClassName:   LoggerUtil
 * @Description: TODO
 * @author:      frankwong
 * @date:        2012-11-4 下午8:29:57
 *
 */
public class LoggerUtil {
	
	public final static Logger logger = LoggerFactory.getLogger(LoggerUtil.class);
	
	public static void LogWarn(String msg) {
		try {
			MDC.put("loginName",
					ActionContext.getContext().getSession().get("username"));
			HttpServletRequest request = Struts2Util.getRequest();
			MDC.put("remoteAddress", request.getRemoteAddr());
			logger.warn(msg);
		} catch (Exception e) {
			
		}
	}
		

	public static void LogInfo(String msg){
		try {
			MDC.put("loginName",
					ActionContext.getContext().getSession().get("username"));
			HttpServletRequest request = Struts2Util.getRequest();
			MDC.put("remoteAddress", request.getRemoteAddr());
			logger.info(msg);
		} catch (Exception e) {
			
		}
	}
}
